'use strict';

module.exports = {
  // 在执行数据库升级时调用的函数，创建 users 表
  up: async (queryInterface, Sequelize) => {
    const { INTEGER, DATE, STRING, BOOLEAN } = Sequelize;
    await queryInterface.createTable('users', {
      id: { type: INTEGER, primaryKey: true, autoIncrement: true },
      account: STRING(30),
      role_id: INTEGER,
      password: STRING(50),
      name: STRING(30),
      email: STRING(50),
      photo: STRING(200), // 头像
      phone: STRING(30),
      description: STRING(255),
      status: BOOLEAN,
      created_at: DATE,
      updated_at: DATE,
    });
    queryInterface.addIndex('users', [ 'account' ], { unique: true });
    queryInterface.addIndex('users', [ 'password' ]);


  },
  // 在执行数据库降级时调用的函数，删除 users 表
  down: async queryInterface => {
    await queryInterface.dropTable('users');
  },
};
